<?php 

/**
* 
*/
class Db
{	//设置连接变量
	private $link;

	public function __construct()
	{	//获取连接
		$this->content();
	}

	private function content()
	{
		$dsn = "mysql:host=localhost;dbname=hdc50";
		$username = "root";
		$password = "";
		try {
			$this->link = new Pdo($dsn,$username,$password);
		} catch (PDOException $e) {
			die($e->getMessage());
		}
		$this->link->query("set names utf8");
	}

	 // 发送查询
	 public function query($sql)
	 {
	 	$result = $this->link->query($sql);

	 	return $result->fetchAll(PDO::FETCH_ASSOC);
	 }


}

 ?>